﻿using Esri.ArcGISRuntime.Tasks.NetworkAnalysis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace classTest
{
    /// <summary>
    /// SetNetworkPathWindow.xaml 的交互逻辑
    /// </summary>
    public partial class SetNetworkPathWindow : Window
    {
        private MainWindow mainWindow;
        public SetNetworkPathWindow(MainWindow mainWindow1)
        {
            InitializeComponent();
            mainWindow = mainWindow1;
        }

        private void OpenFile_Click(object sender, RoutedEventArgs e)
        {
            //新建一个文件对话框
            OpenFileDialog geo = new OpenFileDialog();
            //设置可以在对话框中显示的文件筛选器
            geo.Filter = "文件(*.geodatabase)|*.geodatabase";
            //设置显示在对话框标题栏中的名称
            geo.Title = "设置文件路径";
            //if判断对话框的返回值是否是OK
            if (geo.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                //获取Geodatabase文件路径，并打开
                networkPath.Text = geo.FileName;
            }
        }

        private async void ConfirmBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                RouteTask solveRouteTask = await RouteTask.CreateAsync(networkPath.Text, networkName.Text);

                mainWindow.networkPath = networkPath.Text;
                mainWindow.networkName = networkName.Text;
                this.Close();
            }
            catch
            {
                System.Windows.MessageBox.Show("校验错误，请重新输入");
            }
            
        }
    }
}
